import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    loginState: false, // 是否登录
    username: '', // 用户名
    userid: '', // 用户id
    userphoto: '', // 用户头像
    filterBlur: false, // 背景高斯模糊
    errorBox: false, // 提示框是否显示
    errorBoxSucc: false, // 提示信息是否是正确反馈，如登录成功，复制成功等
    errorBoxText: '', // 提示框内容
    showLogBox: false // 控制登录框的显示隐藏
  },
  actions: {
    changeState (ctx, handle) {
      ctx.commit(handle.name, handle.value)
    }
  },
  mutations: {
    changeLoginState (state, loginState) {
      state.loginState = loginState
    },
    changeUsername (state, username) {
      state.username = username
    },
    changeUserid (state, id) {
      state.userid = id
    },
    changeUserphoto (state, value) {
      state.userphoto = value
    },
    changeFilterBlur (state, bool) {
      state.filterBlur = bool
    }
  }
})
